extends ../../layout

block css
    link(rel="stylesheet", href="/css/dashboard/overlayer.css")
    link(rel="stylesheet", href="/css/dashboard/navbar.css")
    link(rel="stylesheet", href="/css/dashboard/chain-list.css")
block js
    script(data-main="/js/entry/chain/list" src="/js/lib/require.js")
block content
    include ../includes/navbar.pug
    +active("chain")
    section.ds-my-chain.uk-container.uk-container-center
        h1 My Chains
        table.uk-table.uk-table-hover
            thead
                tr
                    th Name
                    th Uptime
                    th Plugin
                    th Mode
                    th Size
                    th Smart Contract Instances
                    th Cost
                    th Status
            tbody
                each cluster in clusters
                    tr
                        td
                            if (cluster.status == "running")
                                a(href=`/dashboard/chain/${cluster.id}`)= cluster.name
                            else
                                = cluster.name
                            .uk-button-dropdown.uk-float-right.uk-margin-right(data-uk-dropdown)
                                div
                                    i.uk-icon-chevron-circle-down(style="color:#ff5003;")
                                .uk-dropdown.uk-dropdown-small
                                    ul.uk-nav.uk-nav-dropdown
                                        li
                                            a(
                                                data-type="edit"
                                                data-chain-id=`${cluster.id}`
                                                data-chain-name=`${cluster.name}`
                                                data-description=`${cluster.description}`
                                            )
                                                i.uk-icon-pencil.uk-margin-right
                                                | Edit
                                        if (cluster.status == "stopped")
                                            li
                                                a(data-type="start" data-chain-id=`${cluster.id}`)
                                                    i.uk-icon-play.uk-margin-right
                                                    | Start
                                        else
                                            li(style="color:#999;padding:3px 15px;")
                                                i.uk-icon-play.uk-margin-right
                                                | Start
                                        if (cluster.status == "running")
                                            li
                                                a(data-type="stop" data-chain-id=`${cluster.id}`)
                                                    i.uk-icon-stop.uk-margin-right
                                                    | Stop
                                        else
                                            li(style="color:#999;padding:3px 15px;")
                                                i.uk-icon-stop.uk-margin-right
                                                | Stop
                                        li
                                            a(data-type="restart" data-chain-id=`${cluster.id}`)
                                                i.uk-icon-repeat.uk-margin-right
                                                | Restart
                                        li
                                            a(data-type="release" data-chain-id=`${cluster.id}`)
                                                i.uk-icon-trash.uk-margin-right
                                                | Release
                        td= cluster.run_time
                        td= cluster.plugin
                        td= cluster.mode == "" ? "-" : cluster.mode
                        td= cluster.size + " nodes"
                        td
                            if (cluster.chaincodes > 1)
                                = cluster.chaincodes + " instances"
                            else
                                = cluster.chaincodes + " instance"
                        td
                            i.uk-icon-database.uk-margin-small-right
                            = cluster.cost + " / day"
                        td
                            if (cluster.status == "running")
                                i.uk-icon-check-circle.uk-margin-small-right(style="color:#659f13;")
                            else if (cluster.status == "stopped")
                                i.uk-icon-stop-circle.uk-margin-small-right(style="color:#e28327;")
                            else
                                i.uk-icon-times-circle.uk-margin-small-right(style="color:#d85030;")
                            = cluster.status
                else
                    tr
                        td.no-result(colspan="8") No result.
        ul#chainListPagination.uk-pagination.uk-pagination-right(
            data-uk-pagination=`{pages:${pages}}`)&attributes(clusters.length ? {} : {"style": "display:none;"})
        .add-section
            a
                img.uk-align-left(src="/images/add.svg")
                | Apply a New Chain